package com.fau.cm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 短信常用短语表实体类
 * @author yangzj
 * @datetime 2014年10月19日,下午6:12:04
 */
@Entity
@Table(name = "medical_call_sms_phrase")
public class MedicalCallSMSPhrase implements Serializable, JSONAware {

	private static final long serialVersionUID = 7667715791117411385L;

	private String id; 						// 短信常用短语表id
	private String content; 				// 内容
	private String type; 					// 短语类型
	private Date createTime = new Date();	// 创建时间
	private Date updateTime = new Date();	// 更新时间
	private String userId;					// 创建人
	
	private String groupId;					// 组id
	private String centerId;				// 中心Id
	private String hospitalId;				// 医院企业id
	
	private String keyType; 				// 字典表短信类型
	private String keyPid; 					// 父id
	private String keyVal;					// 字典表值
	private String ids;						// 多个id
	
	private Date stime;
	private Date etime;
	
	

	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "content", length = 255)
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	@Column(name = "type", length = 32)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "user_id", length = 32)
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@Transient
	public String getKeyType() {
		return keyType;
	}

	public void setKeyType(String keyType) {
		this.keyType = keyType;
	}

	@Transient
	public String getKeyPid() {
		return keyPid;
	}

	public void setKeyPid(String keyPid) {
		this.keyPid = keyPid;
	}

	@Transient
	public String getKeyVal() {
		return keyVal;
	}

	public void setKeyVal(String keyVal) {
		this.keyVal = keyVal;
	}

	@Transient
	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}

	@Transient
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	@Transient
	public String getCenterId() {
		return centerId;
	}

	public void setCenterId(String centerId) {
		this.centerId = centerId;
	}

	@Transient
	public Date getStime() {
		return stime;
	}

	public void setStime(Date stime) {
		this.stime = stime;
	}

	@Transient
	public Date getEtime() {
		return etime;
	}

	public void setEtime(Date etime) {
		this.etime = etime;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("content", content);
		obj.put("typeKV", keyVal);
		obj.put("type", type);
		if(createTime != null){
			obj.put("createTime", DateFormatUtils.format(createTime,"yyyy-MM-dd HH:mm:ss"));
		}
		if(updateTime != null){
			obj.put("updateTime", DateFormatUtils.format(updateTime,"yyyy-MM-dd HH:mm:ss"));
		}
		obj.put("userId", userId);
		return obj.toString();
	}
}
